feat(cli): add --region to project create and fix default region on new app deploys#120
Conversation
…ew app deploys
Add --region <region> flag to `project create`, thread it through implicit
project creation in `app deploy --create-project`, and remove the hardcoded
DEFAULT_REGION ("eu-central-1") fallback so apps created without --region
inherit the project's server-assigned default rather than always landing in
Frankfurt. Also surface `defaultRegion` from the project API in `project show`
output and add `defaultRegion` to ProjectRecord and ProjectSummary types.
The selectRegion stub on DeployInteraction is removed entirely — it was dead
code (interaction: undefined is always passed to sdk.deploy; the branch-app
path calls createBranchApp directly before sdk.deploy, so sdk.deploy always
receives a concrete appId and never reaches #resolveDeployTarget's region
shortcut).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 28 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (11)
WalkthroughThe 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/cli/src/controllers/project.ts (1)
316-324: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winNewly-created project's
defaultRegionis discarded at both create-project call sites.provider.createProjectreturnsdefaultRegion(seeapp-provider.ts), but both places that consume it drop the field when building the resulting project object, so downstream consumers (e.g.project createoutput) never see the server-assigned region even though the type now supports it.
packages/cli/src/controllers/project.ts#L316-L324: includedefaultRegion: created.defaultRegionin the object passed tobindProjectToDirectory.packages/cli/src/controllers/app.ts#L3630-L3658: includedefaultRegion: created.defaultRegionin the returnedProjectCandidate.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/controllers/project.ts` around lines 316 - 324, The newly created project's defaultRegion is omitted at both create-project call sites. In packages/cli/src/controllers/project.ts lines 316-324, update the object passed to bindProjectToDirectory to include created.defaultRegion; in packages/cli/src/controllers/app.ts lines 3630-3658, include created.defaultRegion in the returned ProjectCandidate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/product/command-spec.md`:
- Line 706: Update the `prisma-cli project create` heading to wrap the optional
`--region <region>` argument in brackets, matching the documented optional
behavior and the formatting used by other optional arguments.
---
Outside diff comments:
In `@packages/cli/src/controllers/project.ts`:
- Around line 316-324: The newly created project's defaultRegion is omitted at
both create-project call sites. In packages/cli/src/controllers/project.ts lines
316-324, update the object passed to bindProjectToDirectory to include
created.defaultRegion; in packages/cli/src/controllers/app.ts lines 3630-3658,
include created.defaultRegion in the returned ProjectCandidate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 37460063-f415-4a76-b844-1c31fc99f9f2
📒 Files selected for processing (11)
docs/product/command-spec.mdpackages/cli/src/commands/project/index.tspackages/cli/src/controllers/app.tspackages/cli/src/controllers/project.tspackages/cli/src/lib/app/app-interaction.tspackages/cli/src/lib/app/app-provider.tspackages/cli/src/presenters/project.tspackages/cli/src/types/project.tspackages/cli/tests/app-controller.test.tspackages/cli/tests/app-provider.test.tspackages/cli/tests/project-controller.test.ts
When a deploy runs without --region, the main output now shows the server-resolved region with provenance: "project default" when the project has a defaultRegion, "platform default — pass --region to choose" otherwise. Explicit --region suppresses the provenance suffix. Also propagates defaultRegion through all three toProjectSummary copies (setup.ts, resolution.ts, use-cases/project.ts) and adds a defaultRegion column to `project list` output (absent value: dimmed "none"). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tion Both create-project call sites dropped the provider's defaultRegion, so project create output and the deploy-setup candidate never showed the server-assigned region. Also mark --region optional in the command-spec heading. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
project create --region <region>: new flag threads throughrunProjectCreate→AppProvider.createProject→ SDKcreateProject({ region }). The platform assigns its default when omitted.deployNewAppRegionwas returningDEFAULT_REGION = "eu-central-1"when no--regionis passed. It now returnsundefined, so new apps created without--regionland in the project's server-assigned region instead of always Frankfurt.app deploy --create-project <name> --region <region>:createProjectRegionis now threaded through the deploy project context so the implicit project creation picks up the CLI flag.defaultRegionflows through all threetoProjectSummarycopies (setup.ts, resolution.ts, use-cases/project.ts) intoProjectSummary.project showrenders a region row.project listadds aregioncolumn (absent value: dimmed "none"). On deploy without--region, the main output prints the server-resolved region with provenance: "project default" when the project carries adefaultRegion, otherwise "platform default — pass --region to choose". Explicit--regionsuppresses the provenance suffix.selectRegionstub onDeployInteractionis deleted —interaction: undefinedis always passed tosdk.deploy;createBranchAppcreates the app first sosdk.deployalways receives a concreteappIdand never reaches the#resolveDeployTargetregion shortcut.SDK dependency
The companion SDK PR is prisma/project-compute#108 (makes
region?: stringgenuinely optional in app-creation:regionIdspread only when present,selectRegionhook becomes optional returningstring | undefined, missing-argument region branch removed). The stub removal andcreateBranchAppoptionality already work against the current SDK (v0.34.0) because:createBranchAppalways called beforesdk.deployfor new apps →sdk.deploygets a concreteappId(fast path)CreateProjectOptions.region?: stringalready exists in v0.34.0Breaking behavior change
Previous behavior:
app deploywithout--regionalways created new apps ineu-central-1(the hardcodedDEFAULT_REGION). New behavior: omitting--regionlets the server assign the region from the project default. Users who relied on implicit Frankfurt placement will now see the project's default region applied. The deploy output now makes the server-resolved region visible with provenance so the behavior change is informed rather than silent.Test plan
project create --region us-east-1→createProjectcalled with{ name, region: "us-east-1", signal }(new test inproject-controller.test.ts)app deploy --create-project my-proj --region us-east-1→createProjectcalled with{ name, region: "us-east-1", signal }(new test inapp-controller.test.ts)deployAppwithout--region→ POST/v1/appsbody omitsregionId(existing test, now verifying the bug fix: the old test was named "default Frankfurt region" and assertedregion: "eu-central-1"; updated toregion: undefined)deployAppwithregion: "us-east-1"→ POST/v1/appsbody includesregionId: "us-east-1"(new test inapp-provider.test.ts)--region+ no projectdefaultRegion→ output contains region value and "platform default — pass --region to choose" (new test inapp-presenter.test.ts)--region+ projectdefaultRegionset → output contains region value and "project default" (new test inapp-presenter.test.ts)--region(regionSourcenon-null) → output contains no provenance suffix (new test inapp-presenter.test.ts)pnpm --filter @prisma/cli test)tsc --noEmit)🤖 Generated with Claude Code